home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
-
- static void MyDirProtect(long bits,char *ps)
- {
- long c,x,y;
- char pbits[] = { 'd','e','w','r','a','p','s','h' };
-
- y=1;
- c=bits^15;
-
- for(x=0; x<8; x++) {
- if((c&y)==y) ps[7-x]=pbits[x];
- y=y<<1;
- }
- }
-
-
- static void MyDirDisplay(struct FileInfoBlock *f_info)
- {
- long t,h,m,s;
- char ans[10],date[20];
- struct tm *ut;
-
- t=((f_info->fib_Date.ds_Days+2914L)*86400L);
- t+=(f_info->fib_Date.ds_Minute*60);
- t+=712800L;
- h=(f_info->fib_Date.ds_Minute/60);
- m=((f_info->fib_Date.ds_Minute)-(h*60));
- s=(f_info->fib_Date.ds_Tick/50);
- t+=s;
- t=t-21601L;
- ut=gmtime(&t);
-
- if(ut->tm_year>100) ut->tm_year-=100;
- sprintf(date,"%02d-%02d-%02d",ut->tm_mon+1,ut->tm_mday,ut->tm_year);
-
- t=t+21601L;
- strcpy(ans,"--------");
- MyDirProtect(f_info->fib_Protection,ans);
-
- if(!(f_info->fib_EntryType>0))
- sprintf(GSTR3,"%8ld",f_info->fib_Size);
- else strcpy(GSTR3," Dir");
-
- sprintf(GSTR2," %-25s %s %s %s %02ld:%02ld:%02ld\r\n",f_info->fib_FileName, \
- GSTR3,ans,date,h,m,s);
- AEPutStr(GSTR2);
- }
-
- static void MyDirRecurse(char *path,UBYTE cflag)
- {
- int stat=0;
- BPTR lock;
- struct FileInfoBlock *f_info;
-
- if((f_info=(struct FileInfoBlock *) \
- AllocDosObject(DOS_FIB,NULL))==NULL)
- return;
-
- if((lock=Lock(path,ACCESS_READ))==0) {
- FreeDosObject(DOS_FIB,f_info);
- return;
- }
-
- if((Examine(lock,f_info))==0) {
- sprintf(GSTR2,"%s does not exist\r\n",path);
- AEPutStr(GSTR2);
- UnLock(lock);
- FreeDosObject(DOS_FIB,f_info);
- return;
- }
-
- LineCount=0;
- if(f_info->fib_EntryType>0) {
- sprintf(GSTR2,"Directory of %s\r\n",path);
- AEPutStr(GSTR2);
-
- while(((ExNext(lock,f_info))!=0)&&(!stat)) {
- MyDirDisplay(f_info);
- stat=CheckForPause();
- if(cflag&&!stat&&f_info->fib_Comment[0]!='\0') {
- AEPutStr(" : ");
- AEPutStr(f_info->fib_Comment);
- AEPutStr("\r\n");
- stat=CheckForPause();
- }
- }
- } else MyDirDisplay(f_info);
-
- UnLock(lock);
- FreeDosObject(DOS_FIB,f_info);
- return;
- }
-
- void MyDirAnyWhere(void)
- {
- long stat;
- UBYTE comments;
-
- gnsflag=comments=0;
-
- AEPutStr("\r\n");
- stat=CommandSplit();
- if(stat>1) {
- strcpy(GSTR1,Command[1]);
- if(stat>2) {
- if(Command[2][0]=='C'||Command[2][0]=='c')
- comments=1;
- }
- } else {
- comments=1;
- AEPutStr("FullPath for directory? ");
- stat=LineInput("",GSTR1,250,KEYBOARD_TIMEOUT);
- if(stat<0||GSTR1[0]=='\0') {
- AEPutStr("\r\n");
- return;
- }
- if(FindAssign(GSTR1))
- {
- AEPutStr("\r\nDevice not Mounted.\r\n");
- AEPutStr("\r\n");
- return;
- }
- AEPutStr("Include comments (Y/n)? ");
- stat=LineInput("",GSTR2,3,KEYBOARD_TIMEOUT);
- if(stat<0) return;
-
- if(GSTR2[0]=='n'||GSTR2[0]=='N') comments=0;
- }
- MyDirRecurse(GSTR1,comments);
- AEPutStr("\r\n");
- }
-